<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<jsp:directive.page import="com.knife.review.BlogReview"/>
<jsp:directive.page import="com.knife.blog.logic.CurrentUser"/>
<jsp:directive.page import="com.knife.web.tools.IActiveUser"/>
<jsp:directive.page import="com.knife.review.BlogMessage"/>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>    
    <title>审核</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	 <%
	 String env=" status<=0";
	 IActiveUser user=null;
	 try{
	 user=CurrentUser.getActiveUser();
    	if (com.knife.blog.logic.BlogAdminConfig.getInstance().isAdmin(user.getUserName())){
		}
		else{
			env+=" and belonguser='"+user.getUserName()+"'";
		}
		}catch(Exception e){}
        int perPage = 10;//10条记录每页
		int pages=1;//当前页
		int TotalPages;//总的分页数；
		int allReview;//相对应的总数
		try{
		   if(request.getParameter("pages") == null){
		     pages = 1;
		   }else{pages = Integer.parseInt(request.getParameter("pages"));}
		 }catch(Exception e){
		  out.println("参数有误！"); 
		  return;
		 } 
	    allReview=new BlogMessage().getCount("status<=0");
	    TotalPages=allReview%perPage==0?allReview/perPage:allReview/perPage+1;
		 %>
<link href="/include/css/css.css" rel="stylesheet" type="text/css">
<script language="JavaScript" src="/include/js/forbidNew.js" type="text/JavaScript"></script>
<script language="JavaScript">
function selectAll(obj,value)
{
if(obj.length==undefined)
{
obj.checked=value;
}
for(var i=0;i<obj.length;i++)
obj[i].checked=value;
}
function doEdit()
{
var id=ListForm.cid.value;
if(id=="")
{
alert("请选择要编辑的数据！");
return false;
}
ListForm.parameter.value="edit";
ListForm.submit();
}

function doAdd()
{
ListForm.parameter.value="new";
ListForm.cid.value="";
ListForm.submit();
}
function doCheck()
{
}
function doPublish()
{
var ids="";
var obj=ListForm.cids;
for(var i=0;i<obj.length;i++)
if(obj[i].checked)ids+=obj[i].value+",";
if(ids=="")ids=ListForm.cid.value+",";
ListForm.mulitCid.value=ids;
if(ids==",")
{
alert("请选择要发布的内容！");
return false;
}
}
function selectRow(id)
{
ListForm.cid.value=id;
}
function doDel()
{
var ids="";
var obj=ListForm.cids;
for(var i=0;i<obj.length;i++)
if(obj[i].checked)ids+=obj[i].value+",";
if(ids=="")ids=ListForm.cid.value+",";
ListForm.mulitCid.value=ids;
if(ids==",")
{
alert("请选择要删除的内容！");
return false;
}
if(confirm("文章删除后不能恢复，请问要执行删除操作吗？"))
{
ListForm.parameter.value="del";
ListForm.submit();
}
}
function doCheck()
{
var ids="";
var obj=ListForm.cids;
for(var i=0;i<obj.length;i++)
if(obj[i].checked)ids+=obj[i].value+",";
if(ids=="")ids=ListForm.cid.value+",";
ListForm.mulitCid.value=ids;
if(ids==",")
{
alert("请选择要审核的内容！");
return false;
}
if(confirm("确定要进行审核操作吗？"))
{
ListForm.parameter.value="check";
ListForm.submit();
}
}
function gotoPage(n)
{
	ListForm.page.value=n;
	ListForm.submit();
}
function doSort(fld)
{
	
	if(ListForm.orderType.value=='asc')
			ListForm.orderType.value='desc';
		else
			ListForm.orderType.value='asc';	

	ListForm.orderField.value=fld;
	ListForm.method="post";
	ListForm.parameter.value="query";
    ListForm.submit();
}
function doSearch()
{
ListForm.parameter.value="query";
ListForm.submit();
}

function prePage(){
			fm.pages.value="<%=pages-1%>";
			fm.action="";
			fm.submit();
		}
		function nextPage(){
			fm.pages.value="<%=pages+1%>";
			fm.action="";
			fm.submit();
		}
		//转到某一页
		function goPage()
		{
		var obj=document.getElementById("gopages");
		var pag=0;
		for (var i = 0; i <obj.options.length; i++){
				if(obj.options[i].selected) pag=obj.options[i].value;
			}
			fm.pages.value=pag;
			fm.action="";
			fm.submit();
		}
</script>
  </head>
  
  <body>
 
  
  
    <% 
    
    Vector<BlogMessage> reviews=new BlogMessage().getListAll(" status<=0","",10,pages);
    %>
   <table width="100%" height="100%"  border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" class="Border">
  <tr>
    <td height="38" align="center" valign="bottom"><table width="96%" height="34"  border="0" cellpadding="0" 

cellspacing="0">
      <tr>
        <td valign="middle"><table width="53%"  border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="10%" valign="bottom"><img src="/images/File_13.jpg" width="32" height="32"></td>
                <td width="90%" class="titletxt">博客评论管理</td>
          </tr>
        </table></td>
        <td width="100">&nbsp;</td>
        <td width="120">&nbsp;</td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td align="center" valign="top">
	<div style="height:100%;overflow:auto;">
	<form id="ListForm" name="ListForm"  method="post" action="/message/doManage.jsp">		
	   <input type="hidden" name="parameter" value="">	     
	   <input type="hidden" name="subCommand" value="">
	   <input type="hidden" name="cid"   value="">
	   <input type="hidden" name="mulitCid"   value="">
       <input type="hidden" name="page"   value="1">
       <input name="orderField" type="hidden" value="">
      <input name="orderType" type="hidden" value="">	  
	      <table width="96%"  border="1" cellpadding="4" cellspacing="0" bordercolor="#30524D" bgcolor="CBD9D9" 

class="BorderLine" style="border-collapse: collapse" >
            <thead>
			
              <tr valign="middle"> 
                <td width="20" height="24" align="center" background="/images/index_18.gif" class="title1"  

style="cursor: hand;"><input type="checkbox"  onclick="selectAll(cids,this.checked);"></td>
                
                <td width="50" align="center" style="cursor: hand;" onClick="doSort('inputUser')"  class="title1">评论人</td>
                <td width="50" align="center" style="cursor: hand;" onClick="doSort('inputUser')"  class="title1">内容</td>
                <td width="100" align="center" nowrap style="cursor: hand;" onClick="doSort('inputTime')" class="title1">评论

日期</td>
                
              </tr>
            </thead>
     <%for(int i=0;i<reviews.size();i++){
    BlogMessage review=reviews.get(i);
    %>
              <tr bgcolor="#F8FCF8"  class="coolselect" style="cursor:default " id='<%=review.getCid() %>'   

onmouseover="this.className='MouseOver';" onMouseOut="this.className='MouseOut'" onDblClick="selectRow(this.id);doEdit();" 

onClick="selectRow(this.id);"> 
              <td height="23" title="111"><input type="checkbox" name="cids" value="<%=review.getCid() %>"></td>
              
			
              <td height="23" title="111"><%=review.getInputUser() %></td>
              <td height="23" title="111"><%=review.getContent() %></td>
              <td align="center" nowrap><%=review.getInputTime()%></td>
              <td align="center" nowrap><a href="javascript:selectRow('<%=review.getCid() %>');doCheck();">审核通过</a></td>
              <td align="center" nowrap><a href="javascript:selectRow('<%=review.getCid() %>');doDel();">删除</a></td>
              
            </tr>
      <%
      }
       %>          
                      </table>  
	    </form>
	  </div>
	  
	  </td>
  </tr>
  <tr><td align="center" height="25">
   <table width="92%" height="24"  border="0" cellpadding="0" cellspacing="0">
        <tr valign="bottom">
           <td align="center">
           [共<strong><font color=red><%=allReview%></font></strong>条]
  <%if( pages != 1 ){ %>
  <b><a href="javascript:prePage();">[上一页]</a></b>
  <%}%>
  <%if( pages<TotalPages){%>
  <b><a href="javascript:nextPage();">[下一页]</a></b>
  <%}%>
  <select name="gopages" onChange="goPage()">
  <% for(int i=1;i<=TotalPages;i++){%>
     <option value="<%=i%>" <% if(pages == i){%>selected<% } %>><%= i%></option>
  <% } %>
  </select>
    <form name="fm" action="reviewManage.jsp" method="post">
    <input type="hidden" name="pages" value="<%=pages%>">
	<input type="hidden" name="userids" value="">
   </form>
	</td>
        </tr>
      </table>
  </td></tr>
  <tr>
    <td height="40" align="left" valign="middle"><table height="30"  border="0" cellpadding="0" cellspacing="0">
        <tr> 
          <td width="50" align="left" valign="middle">&nbsp;</td>
       
          <td width="100" valign="middle"><input type="submit" name="Submit323" value="审核通过" onClick="doCheck();"></td>
          <td width="50" valign="middle"><input type="submit" name="Submit322" value="删除" onClick="doDel();"></td>
          <td valign="middle">&nbsp;</td>
        </tr>
      </table></td>       
  </tr>
</table>
  </body>
</html>
